#ifndef TEMPLE_UTIL_CHARSET_H_
#define TEMPLE_UTIL_CHARSET_H_

#include "util/stdc.h"
#include <bitset>
namespace util {

class CharSet
{
public:
    inline CharSet(const char *s)
    {
        set(s, strlen(s));
    }

    inline CharSet(const string &s)
    {
        set(s.c_str(), s.size());
    }

    inline CharSet(const char *s, size_t size)
    {
        set(s, size);
    }

    inline CharSet(const CharSet &other)
    {
        mask = other.mask;
    }

    inline void set(const char *s, size_t size)
    {
        for (size_t i=0; i<size; ++i)
            mask[(unsigned char)s[i]] = true;
    }

    inline bool is_set(char c) const
    {
        return mask[(unsigned char)c];
    }

private:
    std::bitset<256> mask;
};

}
#endif //TEMPLE_UTIL_CHARSET_H_
